<?php
// PHP Proxy 
// Based on example for Yahoo! Web services by Jason Levitt. 
//
// Only responds to HTTP GET as that is all the MythTV XML interface uses
// Only returns text/xml


// Allowed hostname
define ('HOSTNAME', 'http://localhost:6544/');

$QUERYVAR = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY));

// strip the first chracter of the query if it is &
// Dashcode generated javascript seems to add a leading & for some reason
if (substr($QUERYVAR, 0, 1) == "&") {
    $QUERYVAR = substr($QUERYVAR, 1);
}

$url = HOSTNAME.$QUERYVAR;

// Open the Curl session
$session = curl_init($url);

// Don't return HTTP headers. Do return the contents of the call
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

// Make the call
$xml = curl_exec($session);

// The web service returns XML. Set the Content-Type appropriately
header("Content-Type: text/xml");

echo $xml;
curl_close($session);

?>
